#pragma once

#ifndef GUILANE_H
#define GUILANE_H

#include "GUIBase.h"
#include "GUILaneInterface.h"
#include <QList.h>

class GUINest;
class Part;

enum LaneColor
{
	LaneColor_Yellow,
	LaneColor_Purple,
	LaneColor_Green,
	LaneColor_Red,
};

/**
 * @class	GUILane
 *
 * @brief	Graphical user interface lane.
 *
 * @author	Ben White
 */

class GUILane : public GUIBase, public GUILaneInterface
{
	//Q_OBJECT

/**
 * @class	MyPart
 *
 * @brief	My part.
 *
 * @author	Ben White
 */

public:
	GUILane(int startx, int starty, int length, GUINest* nest, LaneColor laneColor = LaneColor_Green);
	GUILane(int startX, int startY, GUINest* nest, LaneColor laneColor);
	~GUILane();

	
	Part* Next;//represents the next part that is ready to leave the lane
	
	void PartTaken(Part* P);//Allows LaneAgent to notify the GUI that a part has been taken from the Lane
	bool HereIsAPart(Part* P);//Allows the LaneAgent to notify the GUI that a part has been added to the Lane*/
	void Start(float speed);
	void setRunSpeed(float speed);
	void Stop();
	void DoBreak();
	void DoFix();
	void setBroken(bool isBroken);
	int Length;
	void DoJamLane();
	void DoClearJam();
	void setNeighbor(GUILane* neighbor);
	void JumpLane();
	
	


private:
	Part* Jam;
	QList<Part*> Jumpers;
	GUILane* Neighbor;
	bool Running;
	bool Broken;
	QList <Part*> PartsInLane;//All the parts in the lane, a part is removed from this list when it is placed in next
	int Capacity;//represents the maximum number of parts that can fit in the lane
	float Speed;
	float LastSpeed;
	qreal EndX;
	qreal MidY;
	int Width; //Lane Width in pixels
	int PartSize; //size of 1 part in pixels
	int NumberOfParts;//represents the current number of parts in the lane, used to determine if the lane is full and parts should fall on the ground
	GUINest* Nest;//pointer to the agent to allow communication
	bool Jump(Part* P);
	void advance(int phase);
	//Ui::GUILaneClass ui;
};

#endif // GUILANE_H
